package com.bw.area.controller;

import com.bw.area.service.TbHouseAreaService;
import com.bw.result.ResultVo;
import com.bw.vo.AreaVo;
import com.bw.vo.TbHouseAreaVo;
import com.bw.vo.TbHouseInfoVo;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * @Author: FanYangJie
 * @BelongsProject: search-house
 * @BelongsPackage: com.bw.area.controller
 * @Date: 2023/11/11 15:39
 * @Description: TODO
 */
@RestController
@Slf4j
@RequestMapping("/area")
@Api(tags =  "地区信息接口")
public class AreaController {
    @Autowired
    private TbHouseAreaService tbHouseAreaService;

    /**
     * @deprecated: TODD 查询出省份
     * @Author: FAnYangJie〔^.べ〕γ
     * @Date: 2023/11/11 15:40
     */
    @PostMapping("/getOneArea")
    @ApiOperation(value = "查询出省份")
    public ResultVo getOneArea(){
        return  tbHouseAreaService.getOneAra();
    }

    /**
     * @deprecated: TODD 获取市,区县
     * @Author: FAnYangJie〔^.べ〕γ
     * @Date: 2023/11/11 16:15
     */
    @PostMapping("/getTwoArea")
    @ApiOperation(value =  "获取市,区县")
    public  ResultVo getTwoArea(@RequestBody TbHouseAreaVo tbHouseAreaVo){
        return  tbHouseAreaService.getTwoArea(tbHouseAreaVo);
    }

    /**
     * @deprecated: TODD 三级联动
     * @Author: FAnYangJie〔^.べ〕γ
     * @Date: 2023/11/11 16:24
     */
    @PostMapping("/getAreaTree")
    @ApiOperation(value = "三级联动")
    public ResultVo getAreaTree(){
        return tbHouseAreaService.getAreaTree();
    }

    /**
     * @deprecated: TODD 通过id获取单条数据
     * @Author: FAnYangJie〔^.べ〕γ
     * @Date: 2023/11/11 16:24
     */
    @PostMapping("/getAreaById")
    public String getAreaById(@RequestParam("id") Integer id){
        return tbHouseAreaService.getAreaById(id);
    }

    /**
     * @description : //TODO获取省市县的名称
     * @param tbHouseInfoVo
     * @return : com.bw.vo.AreaVo
     * @author : kiot
     * @date : 23/11/15 15:43
     */
    @PostMapping("/getAreas")
    public AreaVo getAreas(@RequestBody  TbHouseInfoVo tbHouseInfoVo){
        return tbHouseAreaService.getAreas(tbHouseInfoVo.getProvinceId(),tbHouseInfoVo.getCityId(),tbHouseInfoVo.getCountyId());
    };
}
